// Problem: P3372 【模板】线段树 1
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/P3372
// Memory Limit: 125 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include<iostream>
#include<string.h>

using namespace std;
#define lowbit(x) (x&-(x))
#define ll long long
const int N=100010;

ll tree1[N];
ll tree2[N];

void update1(ll x,ll d)
{
	while(x<=N)
	{
		tree1[x]+=d;
		x+=lowbit(x);
	}
}

void update2(ll x,ll d)
{
	while(x<=N)
	{
		tree2[x]+=d;
		x+=lowbit(x);
	}
}


ll sum1(ll x)
{
	ll ans=0;
	while(x>0)
	{
		ans+=tree1[x];
		x-=lowbit(x);
	}
	return ans;
}

ll sum2(ll x)
{
	ll ans=0;
	while(x>0)
	{
		ans+=tree2[x];
		x-=lowbit(x);
	}
	return ans;
}

int main()
{
	ll n,m;
	scanf("%lld %lld",&n,&m);
	ll old=0,a;
	for(int i=1;i<=n;++i)
	{
		scanf("%lld",&a);
		update1(i,a-old);
		update2(i,(i-1)*(a-old));
		old=a;
	}
	while(m--)
	{
		ll q,l,r,d;
		scanf("%lld",&q);
		if(q==1)
		{
			scanf("%lld %lld %lld",&l,&r,&d);
			update1(l,d);
			update1(r+1,-d);
			update2(l,d*(l-1));
			update2(r+1,(-d)*r);
		}
		else
		{
			scanf(" %lld %lld",&l,&r);
			printf("%lld\n",r*sum1(r)-sum2(r)-(l-1)*sum1(l-1)+sum2(l-1));
		}
	}
	return 0;
}